<?php
/**
 * Created by PhpStorm.
 * User: 秋刀鱼
 * Date: 2018/8/7
 * Time: 9:39
 */
namespace app\models;

use yii\base\Model;
use Yii;
use \common\helps\tools;//使用工具类

Class Research extends Model{

    /**
     * 表名
     */
    protected $table = 'data_yii.special_project';


    /**
     * title 在研列表
     * @param $uid
     * @return array
     */
    public function researchList($uid)
    {
        $query = new \yii\db\Query();
        $list = $query->select(['a.id','a.project_type','a.begin_time','a.end_time','b.item_no','b.belong_company','b.total_money','b.item_no','b.project_name','b.belong_company'])
            ->from('data_yii.special_project_child AS b')
            ->rightJoin('data_yii.special_project AS a', 'b.project_id = a.id')
            ->where(['a.create_id' => $uid,'a.status' => 2])
            ->all();
//        $a = $query->createCommand()->getRawSql();
//        var_dump($a);die;
        return $list;
    }


    /**
     * title 详情
     * @param $id
     * @return array|bool
     */
    public static function detail($id)
    {
        $query =  new \yii\db\Query();
        $list = $query->select(['a.id','a.project_type','a.begin_time','a.end_time','a.grant_way','a.type as main_type','b.item_no','b.project_principal','b.total_money','b.project_name','b.belong_company','b.pid'])
            ->from('data_yii.special_project_child AS b')
            ->rightJoin('data_yii.special_project AS a', 'b.project_id = a.id')
            ->where(['a.id' => $id])
            ->one();
        return $list;
    }









}